<template>
  <div class="blog-card">
    <router-link :to="`/blog/${blog._id}`" class="blog-link">
      <h3 class="blog-title">{{ blog.title }}</h3>
      <p class="blog-summary">{{ blog.summary }}</p>
      <div class="blog-meta">
        <span class="blog-date">{{ blog.date }}</span>
        <span class="blog-category">分类：{{ blog.category.name }}</span>
      </div>
    </router-link>
  </div>
</template>

<script setup>
import { defineProps } from 'vue'

// 定义组件的属性
const props = defineProps({
  blog: {
    type: Object,
    required: true,
    default: () => ({
      _id: '',
      title: '',
      summary: '',
      excerpt: '',
      date: '',
      category: {
        name: '',
        id:''
      },
      tags: [],
      views: 0,
      readTime: 0,
      coverImage: '',
      author: ''
    })
  }
})
</script>

<style scoped>
.blog-card {
  background: white;
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.blog-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #1890ff, #722ed1);
  opacity: 0;
  transition: all 0.3s ease;
}

.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.12);
}

.blog-card:hover::before {
  opacity: 1;
}

.blog-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.blog-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #333;
  transition: color 0.3s ease;
}

.blog-link:hover .blog-title {
  color: #1890ff;
}

.blog-summary {
  font-size: 1rem;
  color: #666;
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blog-meta {
  display: flex;
  gap: 20px;
  font-size: 0.875rem;
  color: #999;
}

.blog-date,
.blog-category {
  display: flex;
  align-items: center;
}

.blog-date::before,
.blog-category::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #999;
  margin-right: 8px;
}
</style>